<?php

/**
 * alltosun.com @提示 at.php
 * ============================================================================
 * 版权所有 (C) 2009-2012 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明: 这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 高竞竞 (gaojj@alltosun.com) $
 * $Date: 2012-3-12 上午10:33:51 $
*/

class Action
{
    public function suggestion()
    {
        return;
        header("Access-Control-Allow-Origin: http://app.alltosun.com");
        header("Access-Control-Allow-Methods: GET");

        // @TODO 测试接口#13434
        $list = array(
            array('id'=>1, 'name'=>'dreamwing', 'source'=>'sina'),
            array('id'=>1, 'name'=>'dreamwing', 'source'=>'tencent'),
            array('id'=>1, 'name'=>'dreamwing', 'source'=>'renren'),
            array('id'=>1, 'name'=>'dreamwing', 'source'=>'kaixin'),
        );
        return array('info'=>'ok', 'data'=>$list);

        $content = Request::Get('k', 'a');
        $user_id = get_user_id();
        $connect_list = get_connect_list();
        $list = array();
        $ext_list = array();

        foreach ($connect_list as $v) {
            if ($v == 'qqweibo') {
                $filter = array(
                    'pinyin LIKE' => '%'.Pinyin($content).'%',
                    'name' => get_connect_user_id($v, $user_id)
                );
            } else {
                 $filter = array(
                    'pinyin LIKE' => '%'.Pinyin($content).'%',
                    'user_id' => get_connect_user_id($v, $user_id)
                );
            }
            $friend_list = _model('friends_'.$v)->getList($filter, 'LIMIT 0,5');
            foreach ($friend_list as $k1=>$v1) {
               if ($v == 'sinaweibo') {
                   $info = array(
                       'id' => $v1['friend_id'],
                       'name' => $v1['screen_name'],
                       'at' => $v1['screen_name'],
                   );
               } elseif ($v == 'qqweibo') {
                    $info = array(
                        'id'=> $v1['friend_name'],
                        'name' => $v1['nick'],
                        'at' => $v1['friend_name'],
                    );
               } elseif ($v == 'renren') {
                    $info = array(
                        'id' => $v1['friend_id'],
                        'name' => $v1['name'],
                        'at' => $v1['name'].'('.$v1['friend_id'].')',
                    );
               } elseif ($v == 'kaixin') {
                   $info = array(
                        'id' => $v1['friend_id'],
                        'name' => $v1['name'],
                        'at' => $v1['name']
                   );
               }
               $info['source'] = $v;
                if ($k1  < 3) {
                    array_push($list, $info);
                } else {
                    array_push($ext_list, $info);
                }
            }
        }

        if (count($list) < 10) {
            array_push($list, $ext_list);
        }
        return array('info'=>'ok', 'data'=>$list);
    }
}
?>